/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package g5.form;

import g5.fw.IField;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author Hue
 */
public class Field implements IField {
    private String pk;
    private String code;
    private String name;
    private String value;
    private String type;
    private boolean bIsMandatory;

    public void setPK(String value) {
        this.pk = value;
    }

    @Override
    public String getPK() {
        return this.pk;
    }

    public void setCode(String value) {
        this.code = value;
    }

    @Override
    public String getCode() {
        return this.code;
    }

    public void setName(String value) {
        this.name = value;
    }

    @Override
    public String getName() {
        return this.name;
    }
    
    public void setValue(String v) {
        this.value = v;
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String getDisplayValue() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    public void setMandatory(boolean v) {
        this.bIsMandatory = v;
    }

    @Override
    public boolean isMandatory() {
        return bIsMandatory;
    }

    @Override
    public String getDtPK() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    public void setType(String v) {
        this.type = v;
    }

    @Override
    public String getType() {
        return type;
    }

    @Override
    public ArrayList getListValues() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getTabIndex() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getPrecision() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getAlignment() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getNumberLength() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public boolean isReadOnly() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getSelectionType() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public JSONObject toJSON() throws JSONException {
        JSONObject jsObj = new JSONObject();
        jsObj.put("pk", getPK());
        jsObj.put("code", getCode());
        jsObj.put("name", getName());
        jsObj.put("value", getValue());
        jsObj.put("type", type);
        jsObj.put("isMandatory", isMandatory());
        /*
        jsObj.put("displayValue", getDisplayValue());
        jsObj.put("tabIndex", getTabIndex());
        jsObj.put("alignment", getAlignment());
        jsObj.put("isReadOnly", isReadOnly());
        jsObj.put("numberLength", getNumberLength());
        jsObj.put("precision", getPrecision());
        */

        return jsObj;
    }
}
